<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <select  id="city"></select>
    <script>
        var obj=[
            {
                id:1001,
                name:"南京"
            },
            {
                id:1002,
                name:"北京"
            },
            {
                id:1003,
                name:"上海"
            }
        ];

        // select的DOM对象.appendChild(option)
        // select的DOM对象.add(option,指定位置)
        
        var city=document.getElementById("city");
        for(var index in obj){
            // console.log(obj[index]);//单个对象
            var option=new Option(obj[index].name,obj[index].id);
            city.add(option);
        }





    </script>
</body>
</html>